<template>
	<view class="leave-examine">
		<!-- <nav-tabs-quit @tapChange='tapChange'> </nav-tabs-quit> -->
		<view v-if="defaultIndex==0" class="has-examine">
			<view  v-if="quitListData.length=='0'" class="data-tip">当前没有任何数据</view>
			<view v-if="quitListData.length!='0'">
				<view v-for="(item,index) in quitListData" class="leave-card" :key='index'>
					<quit-examine-card :quitData='item' @exit='exit' @adopt='adopt'></quit-examine-card>
				</view>
			</view>
		</view>
		<view v-if="defaultIndex==1" class="examine-inforn">
			<view v-if="quitListData.length=='0'" class="data-tip">当前没有任何数据</view>
			<view class="roval-list" v-if="leaveListData.length!='0'">
				<view v-for="(item,index) in leaveListData" :key='index'>
					<approval-quit-exa></approval-quit-exa>
				</view>
			</view>
		</view>
		<sendNews ref="sendNews" @confirm='confirm' :status ='examineStatus'></sendNews>
	</view>
</template>

<script>
	import service from '../../../common/service/new_file.js'
	import apiData from '../../../common/utils/apiData.js'
	import utils from '../../../common/utils/utils.js'
	export default {
		data() {
			return {
				// searchValue:'',
				// nowPeriod:'11',
				defaultIndex:0,
				tabs:['待审批','已审核'],
				quitListData:[],
				isCheck:'N',
				nowItem:null,
			};
		},
		methods:{
			confirm(value){
				let _this = this;
				if(this.examineStatus==1){
					let _this = this
					let data = apiData.setExamineData('6115',true,this.nowItem.data.pk_hi_stapply,value)//FN(billtype, isAdopt,pk)
					service.common(data, {
						success: function(res) {
								uni.showToast({
									title:'已通过'
								})
							_this.getLeaveList()
						},
						fail:function(err){
							console.log(err)
						},
						all:function(all){
							console.log(all)
						}
					})
				}else if(this.examineStatus==0){
					let _this = this
					let data = apiData.setExamineData('6115',false,item.data.pk_hi_stapply)
					service.common(data, {
						success: function(res) {
								uni.showToast({
									title:'已驳回'
								})
								_this.getLeaveList()
						},
						fail:function(err){
							console.log(err)
						}
					})
				} 
			},//审核意见弹出框
			// tapChange(e){
			// 	if(e.index==0){
			// 		this.isCheck = 'N'
			// 	}else if(e.index==1){
			// 		this.isCheck = 'Y'
			// 	}
			// 	this.getLeaveList()
			// },
			adopt(item) {
				this.nowItem = item
				this.examineStatus=1
				this.$refs.sendNews.show()
				
			},
			exit(item) {
				this.nowItem = item
				this.examineStatus=0
				this.$refs.sendNews.show()
			},
			getLeaveList(){
				let _this = this
				let data = apiData.setQuitListData('6115',this.isCheck)
				service.common(data, {
					success: function(res) {
						if(res.data.VALUES.length==0){
							uni.showToast({
								icon:'none',
								title:'未查询到数据'
							})
						}
						_this.quitListData = res.data.VALUES
					// _this.quitListData.sort(utils.compare('apply_date'))	// uni.setStorageSync('LeaveRemineData',JSON.stringify(res.data.VALUES))
					}
				})
			},
		},
		onReady() {
			this.getLeaveList()
		},
		onPullDownRefresh() {
			this.getLeaveList()
		},
		
	}
</script>

<style lang="scss" scoped>
	.head {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 30rpx;
		padding-top: 120rpx;
		.search-btn{
			font-size: 28rpx;
			padding-left: 10rpx;
		}
		.search{
			flex: 1;
		}
	}
	
	.has-examine{
		padding-top: 20rpx;
		padding-bottom: 40rpx;
	}
	.examine-inforn{
		padding-top: 20rpx;
		padding-bottom: 40rpx;
	}
.data-tip{
	padding-top: 100rpx;
	text-align: center;
	color: #949494;
	font-size: 28rpx;
}
.roval-list{
	padding: 20rpx 36rpx;
}
.leave-card{
	margin: 40rpx 0;
}
.date{
	padding: 0 36rpx;
	margin-top: 20rpx;
	font-size: 16px;
	font-weight: 600;
	color: #121F2C;
}
</style>
